﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongHoc_App.MyControls
{
    public partial class ThemTrangHocBa : Form
    {
        public delegate void EventUpdate(object sender, int _idLop, int _idNamHoc);
        public event EventUpdate OkClicked;

        public ThemTrangHocBa()
        {
            InitializeComponent();
        }

        private void ChonLop_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'qLTH.tbl_NamHoc' table. You can move, or remove it, as needed.
            tbl_LopHocTableAdapter.Connection.ConnectionString = 
                tbl_NamHocTableAdapter.Connection.ConnectionString = PublicLib.getStrConn();

            this.tbl_NamHocTableAdapter.FillByFlag(this.qLTH.tbl_NamHoc, PConst.FLAG_NONE);
            this.tbl_LopHocTableAdapter.FillByFlag(this.qLTH.tbl_LopHoc, PConst.FLAG_NONE);
        }

        private void bt_ThemMoi_Click(object sender, EventArgs e)
        {
            int idLop = -1, idNamHoc = -1;
            if (cb_Lop.SelectedIndex != -1)
                idLop = (int)cb_Lop.SelectedValue;
            if (cb_NamHoc.SelectedIndex != -1)
                idNamHoc = (int)cb_NamHoc.SelectedValue;

            if (idLop != -1 && idNamHoc != -1)
            {
                try
                {
                    OkClicked(this, idLop, idNamHoc);
                }
                catch {}

                this.Close();
            }
        }
    }
}
